package org.NooLab.structures.nlp;

import java.io.Serializable;
import java.util.ArrayList;


import org.NooLab.utilities.datatypes.Coordinate2D;



public class PoStagged implements Serializable{
	private static final long serialVersionUID = 83599594699116137L;

	public int index ;
	public String textual = "";
	public String syntacticalTag = "";
	double probability ;

	double bindingForce;
	double separatingForce;
	double transformativeForce;
	
	String usageParam= "";  // case for nouns, and tempus for verbs?
	String baseform  = "";  // e.g. for verbs in order to be able to check thesauri, web
	
	/** we allow for two different onomato schemes<br/>
	 *  note, that these are only very preliminary ascriptions !!! <br/>
	 *  these will just influence the overall properties of the "word" when digested by the associative structure ;<br/>
	 *  an example for a lexonaIndicator is the Dornseiff group
	 */
	public String[] lexonaIndicator = new String[2] ;
	public String[] lexonaMetaLabel = new String[2] ;
	
	/** this describes associative fields as a(n) area(s) on a SOM */
	public ArrayList<Coordinate2D> astFields = new ArrayList<Coordinate2D>() ; // not used so far
	
	/** describes the type of sentence and the role of the word in it */
	public String sententialTag ; // not used so far
	
	transient int textpos = -1;
	
	
	public PoStagged( String txtitem, String tag, double prob){
		textual = txtitem ;
		syntacticalTag = tag ;
		probability = prob ;
	
	}
	
	// ------------------------------------------------------------------------

	public PoStagged clone(){
		PoStagged post = new PoStagged(textual, syntacticalTag, probability );
	
		post.setBindingForce(bindingForce);
		post.setSeparatingForce(separatingForce) ;
		post.setTextpos(textpos) ;
		post.setTransformativeForce(transformativeForce) ;
		post.setUsageParam(usageParam);
		
		return post;
	}
	
	public String getTextual() {
		return textual;
	}

	public void setTextual(String textual) {
		this.textual = textual;
	}

	public String getSyntacticalTag() {
		return syntacticalTag;
	}

	public void setSyntacticalTag(String syntacticalTag) {
		this.syntacticalTag = syntacticalTag;
	}

	public double getProbability() {
		return probability;
	}

	public void setProbability(double probability) {
		this.probability = probability;
	}

	public double getBindingForce() {
		return bindingForce;
	}

	public void setBindingForce(double bindingForce) {
		this.bindingForce = bindingForce;
	}

	public double getSeparatingForce() {
		return separatingForce;
	}

	public void setSeparatingForce(double separatingForce) {
		this.separatingForce = separatingForce;
	}

	public double getTransformativeForce() {
		return transformativeForce;
	}

	public void setTransformativeForce(double transformativeForce) {
		this.transformativeForce = transformativeForce;
	}

	public int getTextpos() {
		return textpos;
	}

	public void setTextpos(int textpos) {
		this.textpos = textpos;
	}

	public String getBaseform() {
		return baseform;
	}

	public void setBaseform(String baseform) {
		this.baseform = baseform;
	}

	public String getUsageParam() {
		return usageParam;
	}

	public void setUsageParam(String usageParam) {
		this.usageParam = usageParam;
	}


	public void setLexonaIndicator( int index , String lexonaStr) {

		if (index<0){
			return;
		}
		if (index>lexonaIndicator.length-1){
			return;
		}
		

		lexonaIndicator[index] = lexonaStr ;

	}
	
	public void setLexonaIndicator(String[] lexonaIndicator) {
		this.lexonaIndicator = lexonaIndicator;
	}

	public String getLexonaIndicator( int index ) {
		if (index<0){
			index=0;
		}
		if (index>lexonaIndicator.length-1){
			index= lexonaIndicator.length-1;
		}
		
		return lexonaIndicator[index];
	}
	
	public String[] getLexonaIndicators() {
		return lexonaIndicator;
	}


	public void setLexonaMetaLabel(String[] lexonaMetaLabel) {
		this.lexonaMetaLabel = lexonaMetaLabel;
	}

	public void setLexonaMetaLabel( int index , String lexonaStr) {
	
		if (index<0){
			return;
		}
		if (index>lexonaMetaLabel.length-1){
			return;
		}
		
	
		lexonaMetaLabel[index] = lexonaStr ;
	
	}

	public String[] getLexonaMetaLabel() {
		return lexonaMetaLabel;
	}

	public String getLexonaMetaLabel( int index ) {
		if (index<0){
			index=0;
		}
		if (index> lexonaMetaLabel.length-1){
			index= lexonaMetaLabel.length-1;
		}
		
		return lexonaMetaLabel[index];
	}
	public Coordinate2D getAstField() {
		return astFields.get(index);
	}

	public void addAstField( Coordinate2D c) {
		this.astFields.add(c) ; 
	}

	public void setAstField( Coordinate2D c) {
		astFields.clear();
		this.astFields.add(c) ; 
	}

	public void setAstFieldAll( ArrayList<Coordinate2D> cc) {
		astFields.clear();
		this.astFields.addAll(cc) ; 
	}

	public void addAstFieldAll( ArrayList<Coordinate2D> cc) {
		this.astFields.addAll(cc) ; 
	}

	public String getSententialTag() {
		return sententialTag;
	}

	public void setSententialTag(String sententialTag) {
		this.sententialTag = sententialTag;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public static int indexOf(  ArrayList<PoStagged> items, 
								PoStagged qtag, 
								int startpos) {
		int index=-1;
		PoStagged item;
		boolean hb;
		
		int s = 0;
		if ((startpos>=0) && (startpos<items.size())){
			s = startpos;
		}
		
		for (int i=s;i<items.size();i++){
			item = items.get(i);
			hb = false;
			
			hb = item.index == qtag.index; 
			
			if (hb){
				hb = item.textual.contentEquals(qtag.textual);
			}
			
			if (hb){
				index=i;
				break;
			}
		}// i->
		
		return index;
	}
	
	
	
}
